package com.kjc.demo.rcservice.service;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kjc.demo.rcservice.bean.AppFileStoreBean;
import com.kjc.demo.rcservice.repository.AppFileStoreMapper;
import com.sdhs.paas.sdk.base.common.BaseDao;
import com.sdhs.paas.sdk.base.common.BasePage;
import com.sdhs.paas.sdk.base.page.Page;
import com.sdhs.paas.sdk.core.PaasBaseException;
import com.sdhs.paas.sdk.core.mybatis.EnablePaasMybatis;

/**
* 描述：AppFileStoreService 服务接口
* @author kangjichang
* @date 2018-09-18
*/

@EnablePaasMybatis
@MapperScan("com.kjc.demo.rcservice.repository")
@Service
public class AppFileStoreService extends BaseDao<AppFileStoreBean, AppFileStoreMapper, Integer>{
		@Override
		public String getMapperNamespace() {
			return AppFileStoreMapper.class.getName();
		}
		
		@Autowired
		private AppFileStoreMapper appFileStoreMapper;
		
		@SuppressWarnings("deprecation")
		public Page<AppFileStoreBean> getPageAppFileStoreList(BasePage pageRequest, AppFileStoreBean appFileStoreBean) {
			pageRequest.setFilters(appFileStoreBean);
			Page<AppFileStoreBean> page = pageQuery(pageRequest);
			return page;
		}
		
		@Transactional(rollbackFor = Exception.class)
		public boolean saveAppFileStore(AppFileStoreBean appFileStoreBean) {
			try {
				int count = appFileStoreMapper.insertAppFileStore(appFileStoreBean);
				return count == 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
	
		@Transactional(rollbackFor = Exception.class)
		public boolean updateAppFileStore(AppFileStoreBean appFileStoreBean) {
			try {
				int count = appFileStoreMapper.updateAppFileStore(appFileStoreBean);
				return count == 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
	
		public AppFileStoreBean getAppFileStoreDetail(String id) {
			return appFileStoreMapper.getAppFileStoreDetail(id);
		}
		
		public boolean deleteAppFileStore(AppFileStoreBean appFileStoreBean){
			return appFileStoreMapper.deleteAppFileStore(appFileStoreBean)>0;
		}
      
}